function th5filecreate_neg()
% Perform negative testing on H5FILECREATE

test_buffered;
test_truncate_not;
return


%--------------------------------------------------------------------------
function test_buffered()
% Can't specify buffer size without buffered.
hfile = 'a.h5';

try
    fid = h5filecreate(hfile,'buffer_size',1000); %#ok<NASGU>
catch me
    if ~strcmp(me.identifier,'HDF5TOOLS:bufferSizeWithoutBuffered')
        rethrow(me)
    end
end


%--------------------------------------------------------------------------
function test_truncate_not()
% the truncate option should blow away any existing file
hfile = 'a.h5';
if exist(hfile,'file')
    delete(hfile);
end
fid = fopen(hfile,'w');
fwrite(fid,5);
fclose(fid);

try
    fid = h5filecreate(hfile,'truncate',false); %#ok<NASGU>
catch me
	switch(me.identifier)
		case { 'MATLAB:H5ML_hdf5:invalidID', ...
		       'MATLAB:hdf5lib2:H5Fcreate:fileCreationFailed', ...
			   'MATLAB:hdf5lib2:H5Fcreate:failure' }
			% 2007b, 
			% 2009a
			% 2009b and up
		otherwise
            rethrow(me)
    end
end